import { BSDataTypeEnum, RecordTypeEnum } from "@/common/constants/other-keys"
import EnumValueDownModal from "@@/components/plugins/EnumValueDownModal.vue"
import TypingValueBfModal from "@@/components/plugins/TypingValueBfModal.vue"
import TypingValueDownModal from "@@/components/plugins/TypingValueDownModal.vue"
import { parseParmeValue } from "@@/utils/parseParamValue"
import { ElInput } from "element-plus"
import { VxeUI } from "vxe-pc-ui"
import VXETable from "vxe-table"

// 创建一个复杂的组合渲染
VxeUI.renderer.add("TypingValueBfModal", {
  tableAutoFocus: "input",
  renderEdit(renderOpts, params) {
    const { row, column } = params
    params.row.typeId = params.row.field.typeId
    params.row.code = params.row.field.code
    let renderInner = <ElInput v-model={row[column.field]} />
    if (row.field.type === BSDataTypeEnum.Base) {
      renderInner = <ElInput v-model={row[column.field]} />
    }
    if (row.field.type === BSDataTypeEnum.Enum) {
      // ……务必设置，便于枚举值选择统一处理
      row.typeId = row.field.typeId
      row.typeCode = row.field.typeCode
      if (row.field.recordType == RecordTypeEnum.Base) {
        renderInner = <EnumValueDownModal params={params} renderOpts={renderOpts} />
      } else {
        renderInner = <TypingValueBfModal params={params} renderOpts={renderOpts} />
      }
    }
    if (row.field.type === BSDataTypeEnum.Class) {
      // ……务必设置，便于枚举值选择统一处理
      row.typeId = row.field.typeId
      row.typeCode = row.field.typeCode
      if (row.field.recordType == RecordTypeEnum.Base) {
        renderInner = (
          <TypingValueDownModal
            params={params}
            renderOpts={renderOpts}
          />
        )
      } else {
        renderInner = (
          <TypingValueBfModal
            params={params}
            renderOpts={renderOpts}
          >
          </TypingValueBfModal>
        )
      }
    }
    return renderInner
  }
})
